package com.qf.feign;

import com.qf.pojo.Customer;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 第二种降级处理的办法
 * 自定义一个工厂
 * @author lixu
 */
@Component
public class SearchFallbackFactory implements FallbackFactory<SearchFeign> {
    /**
     * 降级处理的方法
     * @param throwable
     * @return
     */
    @Override
    public SearchFeign create(Throwable throwable) {
        System.out.println("异常：" + throwable.getMessage());
        return new SearchFeign() {
            @Override
            public String result() {
                return "我是降级FallbackFactory";
            }

            @Override
            public String param1(String name, Integer age) {
                return "我是FallbackFactory方便面FallbackFactory";
            }

            @Override
            public Customer param2(Customer customer) {
                return null;
            }

            @Override
            public Customer findById(Integer id) {
                return null;
            }
        };
    }
}
